/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.aal.bean;

import com.aal.entity.Employee;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author quy
 */
@Stateless
public class EmployeeFacade extends AbstractFacade<Employee> implements EmployeeFacadeLocal {
    @PersistenceContext(unitName = "AAL-ejbPU")
    private EntityManager em;

    protected EntityManager getEntityManager() {
        return em;
    }
    
    public EmployeeFacade() {
        super(Employee.class);
    }

    @Override
    public List<Employee> findUser(String username) {
        Query query = em.createNamedQuery("Employee.findByUsername");
              query.setParameter("username",'%'+username+'%');
        return query.getResultList();
    }
     public Employee loginOk(String username,String password){
        Query query = em.createNamedQuery("Employee.loginOk");
              query.setParameter("username", username);
              query.setParameter("password", password);
        return (Employee) query.getSingleResult();
    }
}
